﻿@model DDDSample.UI.Mvc.Models.CargoViewModel
@{
    ViewBag.Title = "Details for cargo " + Model.Id;
}
<h2>
    Details for cargo
    @Model.TrackingId</h2>
<div>
    <fieldset>
        <legend>Cargo information</legend>
        <p>
            <label>
                Origin:</label>
            @Model.Origin
        </p>
        <p>
            <label>
                Destination:</label>
            @Model.Destination
            <br />
            @Html.ActionLink("Change destination", "ChangeDestination" , new { Model.Id })
        </p>
        <p>
            <label>
                Arrival deadline:</label>
            @Model.ArrivalDeadline
        </p>
        <p>
            @if (Model.Legs.Count == 0)
            {
                <label>
                    Not routed -
                    @Html.ActionLink("Route this cargo", "AssignToRoute", new { Model.Id })</label>
            }
            @if (Model.Misrouted)
            {
                <label>
                    Cargo is misrouted -
                    @Html.ActionLink("Reroute this cargo", "AssignToRoute", new { Model.Id })</label>
            }
        </p>
    </fieldset>
</div>
@if (Model.Legs.Count != 0)
{ 
    <div>
        <table>
            <caption>Itinerary</caption>
                <thead>
                    <tr>
                        <td>
                            Voyage
                        </td>
                        <td>
                            From
                        </td>
                        <td>
                        </td>
                        <td>
                            To
                        </td>
                        <td>
                        </td>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var leg in Model.Legs)
                    {
                        <tr>
                            <td>
                                XXX
                            </td>
                            <td>
                                @leg.LoadLocation.UnLocode.CodeString
                            </td>
                            <td>
                                @leg.UnloadLocation.UnLocode.CodeString
                            </td>
                            <td>
                                @leg.LoadDate
                            </td>
                            <td>
                                @leg.UnloadDate
                            </td>
                        </tr>
                    }
                </tbody>
        </table>
    </div>
}
